<%@ include file = "templates/header.jsp" %>
<%@ page import = "clothing.database.ItemManager" %>
<%@ page import = "clothing.database.Item" %>
<%@ page import = "java.util.ArrayList" %>

<script type="text/javascript">
function process(a)
{
	document.getElementById('id').value=a;
	document.myform.submit();
}

</script>

<h3> Item Page</h3>
<%@ include file="templates/main_nav.jsp" %>

<h2>In Stock Items</h2>
<%
	ItemManager im = new ItemManager();
	ArrayList<Item> list = im.getList();
	out.println("<form name =\"myform\" id=\"myform\" action =\"editItem.jsp\" method=\"post\">");
	out.println("<table>");
%>
	<tr>
		<td><strong>Item ID</strong></td>
		<td><strong>Name</strong></td>
		<td><strong>Color</strong></td>
		<td><strong>Size</strong></td>
		<td><strong>Cost</strong></td>
		<td><strong>Sale Price</strong></td>
        <td><strong>Status</strong></td>
		
	</tr>	
	<input type="hidden" name ="id" id = "id" />
	<% 
	
	for(int i=0;i<list.size();i++)
	{
		out.println("<tr>");
		Item current = list.get(i);
		if(current.getStatus().equalsIgnoreCase("In Stock"))
		{
			out.println("<td>"+ current.getId()+"</td>");
			out.println("<td>"+ current.getName()+"</td>");
			out.println("<td>"+ current.getColor()+"</td>");
			out.println("<td>"+ current.getSize()+"</td>");			
			out.println("<td>"+ current.getCost()+"</td>");
			out.println("<td>"+ current.getSalePrice()+"</td>");
			out.println("<td>"+ current.getStatus()+"</td>");
			
			%>
			
			<td><input type="button" value ="Edit Item" onclick = "process(<%=current.getId() %>);" /></td>
			<% 
		}
			
			
			
			
		out.println("</tr>");
	}
	

	out.println("</table></form>");
	%>
    <h2>Sold Items</h2>
    <% 
	out.println("<table>");
	%>
   
	<tr>
		<td><strong>Item ID</strong></td>
		<td><strong>Name</strong></td>
		<td><strong>Color</strong></td>
		<td><strong>Size</strong></td>
		<td><strong>Cost</strong></td>
		<td><strong>Sale Price</strong></td>
        <td><strong>Status</strong></td>
		
	</tr>	
	
	<% 
	
	for(int i=0;i<list.size();i++)
	{
		out.println("<tr>");
		Item current = list.get(i);
		if(current.getStatus().equalsIgnoreCase("Sold"))
		{
			out.println("<td>"+ current.getId()+"</td>");
			out.println("<td>"+ current.getName()+"</td>");
			out.println("<td>"+ current.getColor()+"</td>");
			out.println("<td>"+ current.getSize()+"</td>");			
			out.println("<td>"+ current.getCost()+"</td>");
			out.println("<td>"+ current.getSalePrice()+"</td>");
			out.println("<td>"+ current.getStatus()+"</td>");
		}
			
		out.println("</tr>");
	}
	

	out.println("</table>");
	
	
	
%>


<h2> Add an Item </h2>
<form action ="addItem.jsp" method = "post" >
	<table>
		<tr>
			<td>Name: </td>
            <td>
                   <select name="name" />
                   <option selected="selected"/> Please Select</option>
                   <option value="T Shirt">T Shirt</option>
                   <option value="Long Sleeve Shirt">Long Sleeve Shirt</option>
                   <option value="No Sleeve Shirt">No Sleeve Shirt</option>
                   <option value="Sweater">Sweater</option>
                   <option value="Skirt">Skirt</option>
                   <option value="Shorts">Shorts</option>
                   <option value="Jeans">Jeans</option>
                   </select>    
            </td>
		</tr>

		<tr>
			<td>Color: </td>
            <td>
                   <select name="color" />
                   <option selected="selected"/> Please Select</option>
                   <option value="Red">Red</option>
                   <option value="Blue">Blue</option>
                   <option value="Yellow">Yellow</option>
                   <option value="Black">Black</option>
                   <option value="White">White</option>
                   <option value="Green">Green</option>
                   <option value="Purple">Purple</option>
                   <option value="Grey">Grey</option>
                   <option value="Orange">Orange</option>
                   </select>    
            </td>
		</tr>

		<tr>
			<td>Size: </td>
            <td>
                   <select name="size" />
                   <option selected="selected"/> Please Select</option>
                   <option value="XS">XS</option>
                   <option value="S">S</option>
                   <option value="M">M</option>
                   <option value="L">L</option>
                   <option value="XL">XL</option>
                   </select>
                   
            </td>
		</tr>
		<tr>
			<td>Cost: </td><td><input type="text" name="cost" /></td>
		</tr>
		<tr>
			<td>Sale Price: </td><td><input type="text" name="sale_price" /></td>
		</tr>
		
		
		<tr>
			<td> </td><td><input type="submit" value= "submit" /></td>
		</tr>
	</table>
	</form>

<%@ include file = "templates/footer.jsp" %>


